define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'games/tradefee/index' + location.search,
                    add_url: 'games/tradefee/add',
                    edit_url: 'games/tradefee/edit',
                    del_url: 'games/tradefee/del',
                    multi_url: 'games/tradefee/multi',
                    import_url: 'games/tradefee/import',
                    table: 'tradefee',
                }
            });

            var table = $("#table");
            
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'game_name', title: __('游戏'), operate: 'LIKE',width:"15%"},
                        {field: 'game_sub_name', title: __('子分类'), operate: 'LIKE',width:"15%"},
                        {field: 'service', title: __('平台服务费'), operate: 'LIKE'},
                        {field: 'trade', title: __('交易手续费'), operate: 'LIKE',width:"15%"},
                        {field: 'safe', title: __('安全服务'), searchList: {"1":__('找回包赔'),"2":__('无服务'),"3":__('心意购')},operate: 'LIKE',width:"15%", formatter: Table.api.formatter.label},
                        // {field: 'type', title: __('商品类型'),searchList: {"1":__('账号 '),"2":__('金币')}, operate: 'LIKE',width:"15%", formatter: Table.api.formatter.label},
                        {field: 'method', title: __('寄售方式'),searchList: {"1":__('平台代发'),"2":__('卖家发货')}, operate: 'LIKE',width:"15%", formatter: Table.api.formatter.label},
                        // {field: 'xyg', title: __('买家是否选择'),searchList: {"1":__('否'),"2":__('是')}, operate: 'LIKE',width:"15%", formatter: Table.api.formatter.label},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                // $('.anquanfuwu').on('change', function (e) {
                //     var pid = $('.anquanfuwu option:selected').text();
                //     if(pid == '心意购'){
                //         $(".xyg_fee").show();
                //         $(".service_fee").hide();
                //         $("#service_fee_val").val("0");
                //     }else{
                //         $(".xyg_fee").hide();
                //         $(".service_fee").show();
                //     }
                // })
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});